]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
MessageTray: untangle click notifications
authorDan Winship <danw@gnome.org>
Thu, 30 Sep 2010 20:41:38 +0000 (16:41 -0400)
committerDan Winship <danw@gnome.org>
Tue, 12 Oct 2010 21:21:58 +0000 (17:21 -0400)
Previously, when you clicked on a notification, it would call
this.source.clicked(), which would emit a 'clicked' signal on the
source, and then various other stuff would happen from there. This
used to make a little bit of sense, when clicking on a notification
was supposed to do the same thing as clicking on its source, but makes
less sense now, when clicking on the source itself *doesn't* call
source.clicked()...

Change it so that when you click on a notification, the notification
emits 'clicked' itself, and the source notices that and calls its
notificationClicked() method, and the various source subclasses do
what they need to do with that, and Source no longer has a clicked
method/signal.

https://bugzilla.gnome.org/show_bug.cgi?id=631042

js/ui/messageTray.js
js/ui/notificationDaemon.js
js/ui/telepathyClient.js
js/ui/windowAttentionHandler.js

index d2eb30e3bd68ce7f404dfac485ee7b385938ee53..a028d32061032f93dab13df6d3676fe2092a84ab 100644 (file)
@@ -116,11 +116,6 @@ Notification.prototype = {
         this._capturedEventId = 0;
         this._keyPressId = 0;
 
-        source.connect('clicked', Lang.bind(this,
-            function() {
-                this.emit('dismissed');
-            }));
-
         source.connect('destroy', Lang.bind(this, this.destroy));
 
         this.actor = new St.Table({ name: 'notification',
@@ -130,7 +125,7 @@ Notification.prototype = {
             function (actor, event) {
                 if (!this._actionArea ||
                     !this._actionArea.contains(event.get_source()))
-                    this.source.clicked();
+                    this.emit('clicked');
             }));
 
         // The first line should have the title, followed by the
@@ -665,26 +660,26 @@ Source.prototype = {
     },
 
     notify: function(notification) {
-        if (this.notification)
+        if (this.notification) {
+            this.notification.disconnect(this._notificationClickedId);
             this.notification.disconnect(this._notificationDestroyedId);
+        }
 
         this.notification = notification;
 
+        this._notificationClickedId = notification.connect('clicked', Lang.bind(this, this._notificationClicked));
         this._notificationDestroyedId = notification.connect('destroy', Lang.bind(this,
             function () {
                 if (this.notification == notification) {
                     this.notification = null;
                     this._notificationDestroyedId = 0;
+                    this._notificationClickedId = 0;
                 }
             }));
 
         this.emit('notify', notification);
     },
 
-    clicked: function() {
-        this.emit('clicked');
-    },
-
     destroy: function() {
         this.emit('destroy');
     },
@@ -696,6 +691,10 @@ Source.prototype = {
         if (this._iconBin.child)
             this._iconBin.child.destroy();
         this._iconBin.child = icon;
+    },
+
+    // Default implementation is to do nothing, but subclass can override
+    _notificationClicked: function(notification) {
     }
 };
 Signals.addSignalMethods(Source.prototype);
index bb37bfd6c0678efb5739dd4f9b9643e1a8ed1f07..3e0bd6b4616b4b114933cff70338c3c55950c05d 100644 (file)
@@ -173,10 +173,6 @@ NotificationDaemon.prototype = {
         let source = new Source(title, pid);
         this._sources[pid] = source;
 
-        source.connect('clicked', Lang.bind(this,
-            function() {
-                source.destroy();
-            }));
         source.connect('destroy', Lang.bind(this,
             function() {
                 delete this._sources[pid];
@@ -281,7 +277,7 @@ NotificationDaemon.prototype = {
         if (notification == null) {
             notification = new MessageTray.Notification(source, summary, body, { icon: iconActor });
             ndata.notification = notification;
-            notification.connect('dismissed', Lang.bind(this,
+            notification.connect('clicked', Lang.bind(this,
                 function(n) {
                     this._emitNotificationClosed(id, NotificationClosedReason.DISMISSED);
                 }));
@@ -433,9 +429,9 @@ Source.prototype = {
         this.useNotificationIcon = false;
     },
 
-    clicked: function() {
+    _notificationClicked: function() {
         this.openApp();
-        MessageTray.Source.prototype.clicked.call(this);
+        this.destroy();
     },
 
     openApp: function() {
index 9a4aaf9a9bba9d46a53cec932b3511ad514bdaad..d2269f6c2de21623427398129ac9dd0be6845100 100644 (file)
@@ -484,7 +484,7 @@ Source.prototype = {
                                            this.ICON_SIZE);
     },
 
-    clicked: function() {
+    _notificationClicked: function(notification) {
         channelDispatcher.EnsureChannelRemote(this._accountPath,
                                               { 'org.freedesktop.Telepathy.Channel.ChannelType': Telepathy.CHANNEL_TEXT_NAME,
                                                 'org.freedesktop.Telepathy.Channel.TargetHandle': this._targetHandle,
@@ -492,8 +492,6 @@ Source.prototype = {
                                               global.get_current_time(),
                                               '',
                                               Lang.bind(this, this._gotChannelRequest));
-
-        MessageTray.Source.prototype.clicked.call(this);
     },
 
     _gotChannelRequest: function (chanReqPath, ex) {
index d990454238f303a210f557c8a3b2a3e1d4c0fca4..b740d8def640d5a3c0aee70940ca71233a782b91 100644 (file)
@@ -66,7 +66,6 @@ WindowAttentionHandler.prototype = {
             source = new Source(app, window);
             this._sources[appId] = source;
             Main.messageTray.add(source);
-            source.connect('clicked', Lang.bind(this, function() { source.destroy(); }));
             source.connect('destroy', Lang.bind(this, function() { delete this._sources[appId]; }));
         }
 
@@ -101,9 +100,8 @@ Source.prototype = {
         return this._app.create_icon_texture(this.ICON_SIZE);
     },
 
-    clicked : function() {
+    _notificationClicked : function(notification) {
         Main.activateWindow(this._window);
-        MessageTray.Source.prototype.clicked.call(this);
+        this.destroy();
     }
-
 };